package smallChanges.lineNumberMapping;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.TreeMap;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;

public class ReissResults
{
    private String method;
    private Map<Integer,ReissScore> scoreMap=new TreeMap<Integer, ReissScore>();
    private ReissScore overallScore=new ReissScore();

    public ReissScore getOverallScore() {
        return overallScore;
    }
    public ReissResults(String method) {
        this.method=method;
    }
    public String getMethod() {
        return this.method;
    }
    public void putScore(int versionNum, ReissScore score) {
        scoreMap.put(versionNum,score);
        overallScore.plus(score);
    }
    
    /**
     * TODO Finish this method
     * 
     * @param filename
     * @return
     * @throws ParserConfigurationException
     * @throws SAXException
     * @throws IOException
     */
    public static ReissScore parseReissOutput(String filename) 
    throws ParserConfigurationException, SAXException, IOException
    {
        ReissScore score=new ReissScore();
        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
        Document doc = docBuilder.parse(new File(filename));
        // normalize text representation
        doc.getDocumentElement ().normalize();
        //this.filename=((Element)doc.getElementsByTagName("TEST").item(0)).getAttribute("FILE");
        //System.out.println ("Root of doc: " +doc.getDocumentElement().getNodeName()); 
        return null;
    }
    /**
     * @return the scoreMap
     */
    public Map<Integer, ReissScore> getScoreMap()
    {
        return scoreMap;
    }
}